#pragma once
#include <bits/types/time_t.h>
#include <cstdarg>
#include <cstdio>
#include <ctime>
#include<iostream>

#define DEBUG 0
#define NORMAL 0
#define WARNING 0
#define FATAL 0

const char* glevelMap[]={
    "DEBUG",
    "NORMAL",
    "WARNING",
    "FATAL"
};

void LogMessage(int level,const char* format,...)
{
    if(level==DEBUG){
        return;
    }
    char stdbuffer[1024];
    time_t Time=time(nullptr);
    snprintf(stdbuffer, sizeof(stdbuffer), "[%s][%ld]", glevelMap[level],Time);
    char logbuffer[1024];
    va_list args;
    va_start(args, format);
    vsnprintf(logbuffer, sizeof(logbuffer), format, args);
    printf("%s %s\n",stdbuffer,logbuffer);
    va_end(args);
}
// void logMessage(int level,const char* format,...)
// {
//     if(level==DEBUG){
//         return;
//     }
//     char stdbuffer[1024];
//     time_t Time=time(nullptr);
//     snprintf(stdbuffer, sizeof(stdbuffer), "[%s] [%ld]", glevelMap[level],Time);
//     char logbuffer[1024];
//     va_list args;
//     va_start(args, format);
//     //vsnprintf 涉及到了可变参数的问题
//     vsnprintf(logbuffer, sizeof(logbuffer), format, args);
//     printf("%s %s\n",stdbuffer,logbuffer);
//     va_end(args);
// }